﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MyMES.IServices.PlanInfos;
using System.Threading.Tasks;
using VOL.Core.Utilities.Response;
using VOL.Entity.DomainModels.Core;
using VOL.Entity.DomainModels;

namespace VOL.WebApi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class PlanInfoController : ControllerBase
    {
        private readonly IPlanInfoServices _planInfoServices;

        public PlanInfoController(IPlanInfoServices planInfoServices)
        {
            _planInfoServices = planInfoServices;
        }
        /// <summary>
        /// 新增质检方案
        /// </summary>
        /// <param name="planInfo">质检方案实体</param>
        /// <returns>操作结果</returns>
        [HttpPost("AddplanInfo")]
        public async Task<ActionResult<WebResponseContent>> Add([FromBody] PlanInfo planInfo)
        {
            return await _planInfoServices.AddPlanInfoModel(planInfo);
        }
        /// <summary>
        /// 修改质检方案
        /// </summary>
        /// <param name="planInfo">质检方案实体</param>
        /// <returns>操作结果</returns>
        [HttpPost("UpdateplanInfo")]
        public async Task<ActionResult<WebResponseContent>> Update([FromBody] PlanInfo planInfo)
        {
            return await _planInfoServices.UpdatePlanInfoModel(planInfo);
        }
        /// <summary>
        /// 修改质检方案
        /// </summary>
        /// <param name="planInfo">质检方案实体</param>
        /// <returns>操作结果</returns>
        [HttpPost("DeleteplanInfo")]
        public async Task<ActionResult<WebResponseContent>> Delete([FromBody] PlanInfo planInfo)
        {
            return await _planInfoServices.DelPlanInfoModel(planInfo);
        }
        [HttpGet("GetPlanInfo")]
        public async Task<PageGridData<PlanInfo>> GetList([FromQuery] string? PlanNo, string? PlanName, int pageIndex = 1, int pageSize = 10)
        {
            return await _planInfoServices.GetPlanInfo(PlanNo, PlanName,pageIndex, pageSize);
        }
    }
}
